const signInBtn = document.getElementById("signIn");
const signUpBtn = document.getElementById("signUp");
const fistForm = document.getElementById("form1");
const secondForm = document.getElementById("form2");
const container = document.querySelector(".container");

signInBtn.addEventListener("click", () => {
    container.classList.remove("right-panel-active");
});

signUpBtn.addEventListener("click", () => {
    container.classList.add("right-panel-active");
});

fistForm.addEventListener("submit", (e) => e.preventDefault());
secondForm.addEventListener("submit", (e) => e.preventDefault());



function register(){

    $.ajax({
        type : 'POST',
        url : "http://localhost:18081//user/register",
        data: {
            username: $("#rUser").val(),
            email: $("#rEmail").val(),
            password: $("#rPassword").val()
        },
        dataType : "json",
        async:true,
        success : function(data) {
            console.log(data);
        },
        error : function(data){
            alert("Error")
        }
    })

}


function login(){
    $.ajax({
        url : "http://localhost:18081/user/login",
        type : 'POST',
        data: {
            email: $("#lEmail").val(),
            password: $("#lPassword").val()
        },
        dataType : "json",
        async:true,
        success : function(data) {
            location.href = "http://localhost:18081/test/test"
        },
        error : function(data){
            alert("Error")
        }
    });
}